#ifndef HTTP_UTIL_H
#define HTTP_UTIL_H

#include <iostream>
#include "httplib.h"
#include "HttpApi.h"
#include "Tools.h"

#define BUFFER_SIZE 65536   // 缓冲区大小
#define PORT 18080   // 端口号

class HttpUtil
{
private:   
    static HttpUtil* singleObjPtr;

public: 
    static HttpUtil* GetGetInstance();
    static void DeleteInstance();

public:
    void Init();//初始化网络模块

private:
    
    HttpUtil(){};
    virtual ~HttpUtil(){};
 
    static int ReqPreprocess(const httplib::Request& req, bool UserCheck, bool ContentCheck, Json::Value& reqContent, Json::Value& errorRes);
    static void ReqPrint(const httplib::Request& req);
    static bool ReqContentAnalysis(const std::string& content, Json::Value& data, Json::Value& errorRes);
    static bool LogInJudge(const httplib::Request& req, Json::Value& errorRes, UserInfo& userInfo);
    static bool LogInJudge(const httplib::Request& req, Json::Value& errorRes);
};

#endif